#pragma strict

@script RequireComponent (ScreenOverlay)

public var minIntensity : float = 1;
public var maxIntensity : float = 1.5;
public var speed : float = 1;

private var screenOverlay : ScreenOverlay;

function Start () 
{
    this.screenOverlay = this.GetComponent(ScreenOverlay);
    this.screenOverlay.enabled = false;
}

function Update () 
{
    var value : float = Mathf.PingPong(Time.time * this.speed, 1.0f);
    this.screenOverlay.intensity = Mathf.Lerp(this.minIntensity, this.maxIntensity, value);
}

function EnableEffect(enabled: boolean)
{
    this.screenOverlay.enabled = enabled;
}